package com.syni.mdd.yhd.common.all.service.impl;

import com.syni.mdd.yhd.common.all.dao.BaseJPADao;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;


public abstract class BaseService<T,ID extends Serializable> {
	
	public abstract BaseJPADao<T,ID> getBaseDao();
	
	@Transactional
	public void save(T entity){
		getBaseDao().save(entity);
	}
	
	@Transactional(readOnly=true)
	public List<T> findAll(){
		return getBaseDao().findAll();
	}
	
	@Transactional(readOnly=true)
	public T findById(ID id){
		return getBaseDao().getOne(id);
	}
	
	@Transactional
	public void delete(T entity){
		getBaseDao().delete(entity);
	}

}
